/*     */ package network;
/*     */ 
/*     */ import java.awt.Canvas;
/*     */ import java.awt.Color;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Image;
/*     */ import java.awt.MediaTracker;
/*     */ import java.awt.Point;
/*     */ import java.awt.Toolkit;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseListener;
/*     */ import java.awt.event.MouseMotionListener;
/*     */ import java.io.PrintStream;
/*     */ import java.util.Enumeration;
/*     */ import player.Move;
/*     */ 
/*     */ final class X1 extends Canvas
/*     */   implements MouseListener, MouseMotionListener
/*     */ {
/*  12 */   private final int xxxo = 50;
/*  13 */   private final String PICS_DIR = "pics/";
/*     */   private static final int SHADOW = 4;
/*     */   private static final int BAD = 5;
/*     */   private Image[] images;
/*     */   private X2 xxo;
/*     */   private Dimension dims;
/*     */   private int size;
/*  23 */   private Point firstPoint = null;
/*     */   private Move currentMove;
/*  25 */   private Point shadowPoint = null;
/*  26 */   private boolean dragging = false;
/*  27 */   private X5 xxooo = null;
/*  28 */   private X6 owner = null;
/*  29 */   private Thread resumeThread = null;
/*     */ 
/*     */   X1() {
/*  32 */     Toolkit localToolkit = Toolkit.getDefaultToolkit();
/*  33 */     this.images = new Image[6];
/*     */ 
/*  46 */     this.images[0] = localToolkit.getImage("pics/black.gif");
/*  47 */     this.images[1] = localToolkit.getImage("pics/white.gif");
/*  48 */     this.images[2] = localToolkit.getImage("pics/empty.gif");
/*  49 */     this.images[3] = localToolkit.getImage("pics/blocked.gif");
/*  50 */     this.images[4] = localToolkit.getImage("pics/shadow.gif");
/*  51 */     this.images[5] = localToolkit.getImage("pics/bad.gif");
/*     */ 
/*  54 */     for (int i = 0; i <= 5; i++) {
/*  55 */       if (this.images[i] == null) {
/*  56 */         System.err.println("Images not found.");
/*  57 */         System.exit(-1);
/*     */       }
/*     */     }
/*     */ 
/*  61 */     MediaTracker localMediaTracker = new MediaTracker(this);
/*  62 */     for (int j = 0; j < 6; j++)
/*  63 */       localMediaTracker.addImage(this.images[j], j);
/*     */     try {
/*  65 */       localMediaTracker.waitForAll(); } catch (InterruptedException localInterruptedException) {
/*     */     }
/*  67 */     setBackground(Color.black);
/*  68 */     this.dims = new Dimension(402, 402);
/*  69 */     addMouseListener(this);
/*  70 */     addMouseMotionListener(this);
/*     */   }
/*     */ 
/*     */   void xoxox(X2 paramX2) {
/*  74 */     this.xxo = paramX2;
/*  75 */     repaint();
/*     */   }
/*     */ 
/*     */   void xooxo(X6 paramX6) {
/*  79 */     this.owner = paramX6;
/*     */   }
/*     */ 
/*     */   public void paint(Graphics paramGraphics) {
/*  83 */     for (int i = 0; i < 8; i++) {
/*  84 */       for (int j = 0; j < 8; j++)
/*  85 */         paramGraphics.drawImage(this.images[this.xxo.oooxx(i, j)], i * 50 + 1, j * 50 + 1, null);
/*     */     }
/*  87 */     if (this.xxooo != null) {
/*  88 */       int n = 0; int i1 = 0;
/*  89 */       for (Enumeration localEnumeration = this.xxooo.oxxoo(); localEnumeration.hasMoreElements(); ) {
/*  90 */         Point localPoint = (Point)localEnumeration.nextElement();
/*  91 */         int k = localPoint.x * 50 + 1 + 25;
/*  92 */         int m = localPoint.y * 50 + 1 + 25;
/*  93 */         if (n != 0) {
/*  94 */           paramGraphics.setColor(Color.red);
/*  95 */           paramGraphics.drawLine(n, i1, k, m);
/*     */         }
/*  97 */         n = k;
/*  98 */         i1 = m;
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   void ooxxx(Move paramMove) {
/* 104 */     switch (paramMove.moveKind) {
/*     */     case 2:
/* 106 */       oooox(paramMove.x2, paramMove.y2);
/*     */     case 1:
/* 109 */       oooox(paramMove.x1, paramMove.y1);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void oooox(int paramInt1, int paramInt2, int paramInt3) {
/* 114 */     Graphics localGraphics = getGraphics();
/* 115 */     localGraphics.drawImage(this.images[paramInt3], paramInt1 * 50 + 1, paramInt2 * 50 + 1, null);
/* 116 */     localGraphics.dispose();
/*     */   }
/*     */ 
/*     */   private void oooox(int paramInt1, int paramInt2) {
/* 120 */     oooox(paramInt1, paramInt2, this.xxo.oooxx(paramInt1, paramInt2));
/*     */   }
/*     */ 
/*     */   public Dimension getMinimumSize() {
/* 124 */     return this.dims;
/*     */   }
/*     */   public Dimension getPreferredSize() {
/* 127 */     return this.dims;
/*     */   }
/*     */ 
/*     */   private Point ooxox(MouseEvent paramMouseEvent) {
/* 131 */     int i = Math.max(Math.min((paramMouseEvent.getX() - 1) / 50, 7), 0);
/* 132 */     int j = Math.max(Math.min((paramMouseEvent.getY() - 1) / 50, 7), 0);
/* 133 */     return new Point(i, j);
/*     */   }
/*     */ 
/*     */   public void mousePressed(MouseEvent paramMouseEvent) {
/* 137 */     if (this.owner == null) return;
/* 138 */     this.firstPoint = ooxox(paramMouseEvent);
/* 139 */     this.currentMove = new Move();
/* 140 */     int i = this.xxo.oooxx(this.firstPoint.x, this.firstPoint.y);
/* 141 */     switch (i) {
/*     */     case 2:
/* 143 */       if (!this.xxo.xxoox(this.owner.x8812)) break;
/* 144 */       this.currentMove.moveKind = 1;
/* 145 */       this.dragging = true;
/* 146 */       mouseDragged(paramMouseEvent); break;
/*     */     case 0:
/*     */     case 1:
/* 151 */       if ((i != this.owner.x8812) || (!this.xxo.xoooo(this.owner.x8812))) break;
/* 152 */       this.currentMove.moveKind = 2;
/* 153 */       this.currentMove.x2 = this.firstPoint.x;
/* 154 */       this.currentMove.y2 = this.firstPoint.y;
/* 155 */       this.dragging = true;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void mouseReleased(MouseEvent paramMouseEvent)
/*     */   {
/* 161 */     if (this.owner == null) return;
/* 162 */     if (this.shadowPoint != null) {
/* 163 */       oooox(this.shadowPoint.x, this.shadowPoint.y);
/* 164 */       this.shadowPoint = null;
/*     */     }
/* 166 */     if (!this.dragging) return;
/* 167 */     this.dragging = false;
/* 168 */     Point localPoint = ooxox(paramMouseEvent);
/*     */ 
/* 170 */     this.currentMove.x1 = localPoint.x;
/* 171 */     this.currentMove.y1 = localPoint.y;
/*     */ 
/* 173 */     if (this.xxo.xooox(this.currentMove, this.owner.x8812))
/* 174 */       synchronized (this.owner) {
/* 175 */         this.owner.xxxooo(this.currentMove);
/* 176 */         this.owner.notify();
/* 177 */         this.owner = null;
/*     */       }
/*     */   }
/*     */ 
/*     */   public void mouseDragged(MouseEvent paramMouseEvent)
/*     */   {
/* 183 */     if (this.owner == null) return;
/* 184 */     if (this.firstPoint == null) return;
/* 185 */     if (!this.dragging) return;
/* 186 */     Point localPoint = ooxox(paramMouseEvent);
/*     */ 
/* 188 */     this.currentMove.x1 = localPoint.x;
/* 189 */     this.currentMove.y1 = localPoint.y;
/*     */ 
/* 191 */     if (this.xxo.oxxxo(localPoint.x, localPoint.y)) {
/* 192 */       if ((this.shadowPoint == null) || (!this.shadowPoint.equals(localPoint))) {
/* 193 */         if (this.shadowPoint != null)
/* 194 */           oooox(this.shadowPoint.x, this.shadowPoint.y);
/* 195 */         int i = this.xxo.oooxx(localPoint.x, localPoint.y);
/* 196 */         if (i == 2) {
/* 197 */           i = 5;
/* 198 */           if (this.xxo.xooox(this.currentMove, this.owner.x8812))
/* 199 */             i = 4;
/*     */         }
/* 201 */         this.shadowPoint = localPoint;
/* 202 */         oooox(this.shadowPoint.x, this.shadowPoint.y, i);
/*     */       }
/*     */     }
/* 205 */     else if (this.shadowPoint != null) {
/* 206 */       oooox(this.shadowPoint.x, this.shadowPoint.y);
/* 207 */       this.shadowPoint = null;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void update(Graphics paramGraphics)
/*     */   {
/* 213 */     paint(paramGraphics);
/*     */   }
/*     */ 
/*     */   void oxoox(X5 paramX5) {
/* 217 */     this.xxooo = paramX5;
/* 218 */     repaint();
/*     */   }
/*     */ 
/*     */   private void pointToMove(Point paramPoint, Move paramMove)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void mouseMoved(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void mouseClicked(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void mouseEntered(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   public void mouseExited(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ }

/* Location:           C:\Users\Justin\Desktop\pj2\
 * Qualified Name:     network.X1
 * JD-Core Version:    0.6.0
 */